import { extend } from 'vee-validate'
import { required } from 'vee-validate/dist/rules'

extend('phoneRequired', {
  ...required,
  message: '请输入手机号',
})

export const phoneReg = /^1[3-9][0-9]{9}$/

extend('phone', {
  validate(phone) {
    return phoneReg.test(phone)
  },
  message: '手机号不符合规范',
})

extend('passwordRequired', {
  ...required,
  message: '请输入密码',
})

const passwordReg = /^[A-Za-z0-9_]{6,18}$/

extend('password', {
  validate(password) {
    return passwordReg.test(password)
  },
  message: '密码不符合规范',
})
